<?php
require_once('../../includes/global.php');
$action = @trim($_GET['action']);
if($action == 'reload_validate_img') {
    $w  = @(int)$_GET['w'];
    $h  = @(int)$_GET['h'];
    $s  = @(int)$_GET['s'];


    if($w <= 0) $w = 50;
    if($h <= 0) $h = 20;

    if($s == 3) {
        define('IN_ADMIN', 1);
    } elseif($s == 2) {
        define('IN_MEMBER', 1);
    } else {
    }
    echo get_validate_code($w, $h);
} 
elseif($action == 'reload_validate_img2') {
    $w  = @(int)$_GET['w'];
    $h  = @(int)$_GET['h'];
    $s  = @(int)$_GET['s'];


    if($w <= 0) $w = 50;
    if($h <= 0) $h = 20;

    if($s == 3) {
        define('IN_ADMIN', 1);
    } elseif($s == 2) {
        define('IN_MEMBER', 1);
    } else {
    }
    echo get_validate_code2($w, $h);
}elseif ($action == 'query') {
    $code   = trim($_REQUEST['code']);
    $front  = @(int)$_REQUEST['front'];
    @session_start();
    if(1 == $front){
        $sess_key = $G_front_session_key;
    }else{
        $sess_key = $G_admin_session_key;
    }
    if(strtolower($code) == strtolower($_SESSION[$sess_key]['validate_code'])) {
        echo "ok";
    } else {
        echo "error";
    }
}
?>